		//课程视频AJAX
		var id = window.location.search;
		var lid = id.split('=')[1];
		console.log(lid)
		$.get(`/video/course_v?lid=${lid}`, data => {
			console.log(data)
			const {
				course_video: v,
				course_title: t,
				course_teach:teach,
				course_hourse:h,
				course_type:y,
				course_brief:b	
			} = data[0];
			const html = `<source src="${v}" type="video/mp4"></source>`
			$('#video').append(html);
			const html_1 = `<span>${t}</span>`
			$('.title').append(html_1);
			const html_2=`
			<div class="course_title">${t}</div>
			<div class="course_teach">讲师：${teach}</div>
			<div class='course_ht'>
				学习时长：<span class="course_hourse">${h}小时</span>
				课程类型：<span class="course_type">${y}</span>
			</div>`
			$('.right_top').append(html_2);
			const html_3=`<div>&nbsp;&nbsp;&nbsp;&nbsp;${b}</div>`
			$('.course_brief').append(html_3);
		})
/*********************************************************/		
		
		// 返回到上一页
		$("#back").click(function(){
			console.log(1)
			window.history.back(-1);
		})
		
			let player = document.getElementById("video");
			//监听拖拽更新
			range.addEventListener("change", function() {
				console.log(range.value);
				player.currentTime = range.value;
				$('#range').attr('value', this.value);
				$('#range').css('background', 'linear-gradient(to right, rgb(255,205,0), white ' + this.value +
					'%, white)');
			});

			//为player绑定timeupdate事件
			player.addEventListener("timeupdate", function() {
				let ct = player.currentTime;
				let dt = player.duration;
				console.log(`ct:${ct} dt:${dt}`);
				//更新进度条
				range.max = dt;
				range.value = ct;

				// 初始化显示总时长文本
				// 当播放器已经加载玩数据源的基本信息后执行
				player.addEventListener("loadedmetadata", function() {
					let dt = player.duration;
					let dtstr = moment.unix(dt).format("mm:ss");
					rspan.innerHTML = dtstr;
				});

				// 更新文本
				let ctstr = moment.unix(ct).format("mm:ss");
				let dtstr = moment.unix(dt).format("mm:ss");
				console.log(`ct:${ctstr} dt:${dtstr}`);
				lspan.innerHTML = ctstr;
				rspan.innerHTML = dtstr;
			});
			// 0.5倍速
			btn_05.onclick = function() {
				player.playbackRate = 0.5;
				console.log(player.playbackRate);
			};
			// 1倍速
			btn_1.onclick = function() {
				player.playbackRate = 1;
				console.log(player.playbackRate);
			};
			// 2倍速
			btn_2.onclick = function() {
				player.playbackRate = 2;
				console.log(player.playbackRate);
			};
			// 音量+
			btn_vp.onclick = function() {
				player.volume = Math.min(player.volume + 0.1, 1);
				console.log(player.volume);
			};
			//音量减-
			btn_vm.onclick = function() {
				player.volume = Math.max(player.volume - 0.1, 0);
				console.log(player.volume);
			};
			// 播放或者暂停
			btn_play.onclick = function() {
				if (player.paused) {
					player.play();
				} else {
					player.pause();
				}
			};
			// 弹幕
			let ctx = cvs.getContext('2d');
			let dmlist = []
			send.addEventListener('click', function() {
				let text = msg.value
				console.log(text)
				dmlist.push({
					text: text,
					x: 600,
					y: Math.ceil(Math.random() * 15) * 24
				})
			})

			console.log(color)
			function draw() {		
				ctx.clearRect(0, 0, 900, 360);
				dmlist.forEach(item => {
					// console.log('11');
					let obj=document.getElementById('color')
					let color=obj.options[obj.selectedIndex].text
					item.x--
					ctx.font = '24px 微软雅黑'
					ctx.fillStyle = `${color}`
					ctx.fillText(item.text, item.x, item.y)
				})
			 window.requestAnimationFrame(draw)
			}
			draw()
/*******************************************************************/
$('.right_bottom_top>span').click(function() {
		$(this).addClass('cur').siblings().removeClass('cur')
		// 获取当前点击项的 自定义属性 index
		const index = this.dataset.index
		console.log(index)
		// $div: 通过序号读取的 标题对应的 内容的div
		const $div = $('.right_bottom>div').eq(index)
		$div.addClass('cur1').siblings().removeClass('cur1')
})
/*******************************************************/
//聊天内容插入数据库
$('#fasong').click(function(){
	//获取输入框的值
	const content=$('#input').val()
	//获取当前登录的用户名
	let stu_name = sessionStorage.getItem('stu_name')
	console.log(stu_name);
	//发送ajax请求
	$.ajax({
		type:'post',
		url:'/video/chat',
		dataType:'json',
		data:{
			'content':content,
			'stu_name':stu_name,
		},
		success: function (result){
			
		}
	})
})
// 从数据库中获取聊天内容，每隔1秒中发送一次请求
setInterval(function() {
	const url=`/video/select_content`
  $.get(url,data=>{
	  let html = ""
		data.forEach(function(item,index){
			html +=`
			<div>
			<label>${item.name}:</label>
			<span>${item.content}</span>
			</div>
			`
		})
		document.getElementById("chat").innerHTML = html 
		toBottom()//滚动条
  })
}, 100);
//监听输入框
document.getElementById("fasong").setAttribute("disabled", "disabled")
$('#input').on('input propertychange',function(){
	const content=$('#input').val()
	console.log(content)
	if(!content.length){
	$('#fasong').attr("disabled","disabled" );//禁用按钮
	}else{
		$('#fasong').removeAttr("disabled");
	}		
})
//聊天框滚动到底部
function toBottom() {
	let chat = document.querySelector(".chatbox")
	chat.scrollTop = chat.scrollHeight	
}







